package com.xydtech.ecard.merchant.controller;

import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.merchant.domain.EcardBranchAgriculturePartInfo;
import com.xydtech.ecard.merchant.service.IEcardBranchPartInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 新型农业主体成员统计Controller
 *
 * @author yuzhiguo
 * @date 2024-09-12 上午9:09
 */
@Controller
@RequestMapping("/merchant/branchAgrPartInfo")
public class EcardBranchAgriculturePartInfoController extends BaseController {

    @Autowired
    private IEcardBranchPartInfoService ecardBranchPartInfoService;

    private String prefix = "merchant";

    @RequiresPermissions("merchant:branchAgrPartInfo:view")
    @GetMapping()
    public String merchant()
    {
        return prefix + "/branchAgriculturePartInfo";
    }

    @RequiresPermissions("merchant:branchAgrPartInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardBranchAgriculturePartInfo ecardBranchAgriculturePartInfo) {
        String salt = getSalt();//盐值
        startPage();
        List<EcardBranchAgriculturePartInfo> list = ecardBranchPartInfoService.selectBranchAgriculturePartInfoList(ecardBranchAgriculturePartInfo, salt);
        return getDataTable(list);
    }

    @RequiresPermissions("merchant:branchAgrPartInfo:export")
    @Log(title = "导出农业成员统计信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardBranchAgriculturePartInfo ecardBranchAgriculturePartInfo)
    {
        String salt = getSalt();//盐值
        List<EcardBranchAgriculturePartInfo> list = ecardBranchPartInfoService.selectBranchAgriculturePartInfoList(ecardBranchAgriculturePartInfo, salt);
        ExcelUtil<EcardBranchAgriculturePartInfo> util = new ExcelUtil<EcardBranchAgriculturePartInfo>(EcardBranchAgriculturePartInfo.class);
        return util.exportExcel(list, "农业成员统计");
    }
}
